package cn.com.nes.site.entity.em.project;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 项目级别 枚举
 *  值域对应 t_param 表 param_type=93
 */
public enum ProjectLevelEnum {
    _01("01", "一级"),
    _02("02", "二级"),
    _03("03", "三级"),
    _04("04", "四级"),
    _05("05", "五级"),
    ;

    private String key;

    private String value;

    ProjectLevelEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static String getKey(String key) {
        Map<String, String> map = new HashMap<>();
        for (ProjectLevelEnum projectLevelEnum : values()) {
            map.put(projectLevelEnum.getKey(), projectLevelEnum.getValue());
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的项目级别");
        }
        return map.get(String.valueOf(key));
    }

}
